SourceForge.net Logo

Ohloh project report for domingo

Examples

We have written some samples to demonstrate the usage of domingo. You can find them in CVS in the samples package .

Usage Patterns

Agent and Context Document

The following usage pattern shows how to write an agent and to access and modify the context document.

Please note the following:

  • Derive the agent class from the domingo agent base class DAgentBase
  • Use the method getDSession as the starting point into the domingo API.
  • You never have to recycle your objects
  • You don't have to handle exceptions, but you can do optionally, just as in Lotus-Script
public class AgentContext extends DAgentBase {
    public void main() {
        DDocument doc = getDSession().getAgentContext().getDocumentContext();
        // do something with the document
        doc.save();
    }
}

Agent and Unprocessed Documents

The following usage pattern shows how to write an agent and iterate over all unprocessed documents.

Please note the following:

  • Iterating a view or a document collection is always done with an Iterator from the Java collections API
  • You never have to recycle your objects, even when looping over tens of thousands of documents
  • You don't have to handle exceptions, but you can do it optionally, just as in Lotus-Script
public class AgentContext extends DAgentBase {
    public void main() {
        DDocumentCollection docs = getDSession().getAgentContext().getUnprocessedDocuments();
        Iterator i = docs.getAllDocuments();
        while (i.hasNext()) {
            DDocument doc = (DDocument) i.next();
            try {
                // do something with the document
                doc.save();
            } catch (DNotesRuntimeException e) {
                e.printStackTrace();
            }
        }
    }
}

Accessing Views and View Entries

The following usage pattern shows how to write a local client, access a view and iterate over all view entries. 'local client' means this application can be started directly in your Java development environment, outside of Lotus Notes.

Please note the following:

  • Use the static getInstance method of class DNotesFactory to get a starting point into the domingo API
  • Use the factory instance to get a domingo session
public static void main(String[] args) throws DNotesException {
    DNotesFactory factory = DNotesFactory.getInstance();
    DSession session = factory.getSession();
    DDatabase database = session.getDatabase("", "names.nsf");
    DView view = database.getView("($Users)");
    Iterator entries = view.getAllEntries();
    while (entries.hasNext()) {
        DViewEntry entry = (DViewEntry) entries.next();
        System.out.println(entry.getColumnValues().get(0));
    }
}